home *** CD-ROM | disk | FTP | other *** search
/ Delphi 2.0 - Programmer's Utilities Power Pack / Delphi 2.0 Programmer's Utilities Power Pack.iso / e_to_l / itgraph / msvc15 / itgdmvw.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1996-09-15  |  15.7 KB  |  459 lines

  1. // itgdmvw.cpp : implementation of the CItgDemoView class
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "itgdemo.h"
  6.  
  7. #include "mainfrm.h"
  8. #include "itgdmdoc.h"
  9. #include "itgdmvw.h"
  10. #include "dlgitem.h"
  11. #include "dlgline.h"
  12.  
  13. #include "itgdefs.h"
  14.  
  15. #ifdef _DEBUG
  16. #undef THIS_FILE
  17. static char BASED_CODE THIS_FILE[] = __FILE__;
  18. #endif
  19.  
  20. /////////////////////////////////////////////////////////////////////////////
  21. // CItgDemoView
  22.  
  23. IMPLEMENT_DYNCREATE(CItgDemoView, CFormView)
  24.  
  25. BEGIN_MESSAGE_MAP(CItgDemoView, CFormView)
  26.     //{{AFX_MSG_MAP(CItgDemoView)
  27.     ON_WM_SIZE()
  28.     ON_VBXEVENT(VBN_ITEMCONNECT, IDC_ITGRAPH1, OnItemconnectItgraph1)
  29.     ON_VBXEVENT(VBN_KEYPRESS, IDC_ITGRAPH1, OnKeypressItgraph1)
  30.     ON_VBXEVENT(VBN_ITEMCLICK, IDC_ITGRAPH1, OnItemclickItgraph1)
  31.     ON_VBXEVENT(VBN_CLICK, IDC_ITGRAPH1, OnClickItgraph1)
  32.     ON_VBXEVENT(VBN_SELECTRECT, IDC_ITGRAPH1, OnSelectrectItgraph1)
  33.     ON_VBXEVENT(VBN_ITEMDBLCLICK, IDC_ITGRAPH1, OnItemdblclickItgraph1)
  34.     ON_VBXEVENT(VBN_DBLCLICK, IDC_ITGRAPH1, OnDblclickItgraph1)
  35.     ON_VBXEVENT(VBN_ITEMMOUSEMOVE, IDC_ITGRAPH1, OnItemmousemoveItgraph1)
  36.     ON_VBXEVENT(VBN_MOUSEDOWN, IDC_ITGRAPH1, OnMousedownItgraph1)
  37.     ON_VBXEVENT(VBN_LINEDBLCLICK, IDC_ITGRAPH1, OnLinedblclickItgraph1)
  38.     //}}AFX_MSG_MAP
  39.     // Standard printing commands
  40.     ON_COMMAND(ID_FILE_PRINT, CFormView::OnFilePrint)
  41.     ON_COMMAND(ID_FILE_PRINT_PREVIEW, CFormView::OnFilePrintPreview)
  42. END_MESSAGE_MAP()
  43.  
  44. /////////////////////////////////////////////////////////////////////////////
  45. // CItgDemoView construction/destruction
  46.  
  47. CItgDemoView::CItgDemoView()
  48.     : CFormView(CItgDemoView::IDD)
  49. {
  50.     //{{AFX_DATA_INIT(CItgDemoView)
  51.     m_ITGraph = NULL;
  52.     //}}AFX_DATA_INIT
  53.  
  54.     m_sFindStr = "";
  55.     m_bRandomSizedNodes = FALSE;
  56.     m_nPrintoutType = 1; // Print the Graph
  57. }
  58.  
  59. CItgDemoView::~CItgDemoView()
  60. {
  61. }
  62.  
  63. void CItgDemoView::DoDataExchange(CDataExchange* pDX)
  64. {
  65.     CFormView::DoDataExchange(pDX);
  66.     //{{AFX_DATA_MAP(CItgDemoView)
  67.     DDX_VBControl(pDX, IDC_ITGRAPH1, m_ITGraph);
  68.     //}}AFX_DATA_MAP
  69. }
  70.  
  71. /////////////////////////////////////////////////////////////////////////////
  72. // CItgDemoView printing
  73.  
  74. BOOL CItgDemoView::OnPreparePrinting(CPrintInfo* pInfo)
  75. {
  76.     if(m_nPrintoutType == 1) {
  77.         HDC hGraphDC = ::GetDC(m_ITGraph->m_hWnd);
  78.         ptPix_G.x = ::GetDeviceCaps(hGraphDC, LOGPIXELSX);
  79.         ptPix_G.y = ::GetDeviceCaps(hGraphDC, LOGPIXELSY);
  80.         ::DeleteDC(hGraphDC);
  81.         
  82.         m_ITGraph->SetNumProperty("PrintToDC", 0); // sets SelectRect to entire graph
  83.         rcGraph.left = (int)m_ITGraph->GetNumProperty("SelectRectLeft");
  84.         rcGraph.top = (int)m_ITGraph->GetNumProperty("SelectRectTop");
  85.         rcGraph.right = rcGraph.left + (int)m_ITGraph->GetNumProperty("SelectRectWidth");
  86.         rcGraph.bottom = rcGraph.top + (int)m_ITGraph->GetNumProperty("SelectRectHeight");
  87.         
  88.         int scale = (int)m_ITGraph->GetNumProperty("DrawScale");
  89.         
  90.         mInches_X = MulDiv(rcGraph.Width(), (scale ? scale : 100), ptPix_G.x);
  91.         nPages_X = mInches_X / 750;
  92.         if(mInches_X % 750)
  93.             nPages_X++;
  94.             
  95.         mInches_Y = MulDiv(rcGraph.Height(), (scale ? scale : 100), ptPix_G.y);
  96.         nPages_Y = mInches_Y / 900;
  97.         if(mInches_Y % 900)
  98.             nPages_Y++;
  99.     
  100.         rcPage_G.left = 0;
  101.         rcPage_G.top = 0;
  102.         rcPage_G.right = MulDiv(rcGraph.Width(), 750, mInches_X);
  103.         rcPage_G.bottom = MulDiv(rcGraph.Height(), 900, mInches_Y);
  104.     
  105.         pInfo->SetMaxPage(nPages_X * nPages_Y);
  106.     }
  107.     
  108.     return DoPreparePrinting(pInfo);
  109. }
  110.  
  111. void CItgDemoView::OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo)
  112. {
  113.     if(m_nPrintoutType == 1) { // printing the entire graph; we must set it up
  114.         ptPix_P.x = pDC->GetDeviceCaps(LOGPIXELSX);
  115.         ptPix_P.y = pDC->GetDeviceCaps(LOGPIXELSY);
  116.  
  117.         int scale = (int)m_ITGraph->GetNumProperty("DrawScale");
  118.         
  119.         rcPrintout.left = 0;
  120.         rcPrintout.top = 0;
  121.         rcPrintout.right = rcPrintout.left + MulDiv(mInches_X, ptPix_P.x, 100);
  122.         rcPrintout.bottom = rcPrintout.top + MulDiv(mInches_Y, ptPix_P.y, 100);
  123.         
  124.         rcPage_P.left = ptPix_P.x / 2;
  125.         rcPage_P.top = ptPix_P.y;
  126.         rcPage_P.right = rcPage_P.left + MulDiv(750, ptPix_P.x, 100);
  127.         rcPage_P.bottom = rcPage_P.top + MulDiv(900, ptPix_P.y, 100);
  128.     }
  129. }
  130.  
  131. void CItgDemoView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
  132. {
  133.     // TODO: add cleanup after printing
  134. }
  135.  
  136. void CItgDemoView::OnPrint(CDC* pDC, CPrintInfo* pInfo)
  137. {
  138.     if(m_nPrintoutType == 1) {
  139.         CRect rcSel;
  140.         rcSel.left = rcGraph.left + ((pInfo->m_nCurPage-1)%nPages_X) * rcPage_G.Width();
  141.         rcSel.top = rcGraph.top + ((pInfo->m_nCurPage-1)/nPages_X) * rcPage_G.Height();
  142.         rcSel.right = rcSel.left + rcPage_G.Width();
  143.         rcSel.bottom = rcSel.top + rcPage_G.Height();
  144.         m_ITGraph->SetNumProperty("SelectRectLeft", rcSel.left);
  145.         m_ITGraph->SetNumProperty("SelectRectTop", rcSel.top);
  146.         m_ITGraph->SetNumProperty("SelectRectWidth", rcSel.Width());
  147.         m_ITGraph->SetNumProperty("SelectRectHeight", rcSel.Height());
  148.         
  149.         m_ITGraph->SetNumProperty("PrintRectLeft", rcPage_P.left);
  150.         m_ITGraph->SetNumProperty("PrintRectTop", rcPage_P.top);
  151.         m_ITGraph->SetNumProperty("PrintRectWidth", rcPage_P.Width());
  152.         m_ITGraph->SetNumProperty("PrintRectHeight", rcPage_P.Height());
  153.         
  154.         char tmpStr[80];
  155.         int charWidth = pDC->GetTextExtent("M", 1).cx;
  156.         int charHeight = pDC->GetTextExtent("M", 1).cy;
  157.         int oldTextAlign = pDC->SetTextAlign(TA_CENTER + TA_TOP);
  158.         sprintf(tmpStr, "ITGraph Property Playground");
  159.         pDC->TextOut(rcPage_P.left + rcPage_P.Width()/2, rcPage_P.top - 3*charHeight,
  160.             tmpStr, strlen(tmpStr));
  161.         pDC->SetTextAlign(TA_CENTER + TA_BOTTOM);
  162.         sprintf(tmpStr, "Page %d of %d", pInfo->m_nCurPage, nPages_X * nPages_Y);
  163.         pDC->TextOut(rcPage_P.left + rcPage_P.Width()/2, rcPage_P.top + rcPage_P.Height() + 3*charHeight,
  164.             tmpStr, strlen(tmpStr));
  165.         pDC->SetTextAlign(oldTextAlign);
  166.         
  167.         pDC->ExcludeClipRect(pInfo->m_rectDraw.left-ptPix_P.x, pInfo->m_rectDraw.top-ptPix_P.y,
  168.             rcPage_P.left - charWidth, pInfo->m_rectDraw.bottom+ptPix_P.y);
  169.         pDC->ExcludeClipRect(rcPage_P.right + charWidth, pInfo->m_rectDraw.top-ptPix_P.y,
  170.             pInfo->m_rectDraw.right+ptPix_P.x, pInfo->m_rectDraw.bottom+ptPix_P.y);
  171.         pDC->ExcludeClipRect(pInfo->m_rectDraw.left-ptPix_P.x, pInfo->m_rectDraw.top-ptPix_P.y,
  172.             pInfo->m_rectDraw.right+ptPix_P.x, rcPage_P.top - charHeight);
  173.         pDC->ExcludeClipRect(pInfo->m_rectDraw.left-ptPix_P.x, rcPage_P.bottom + charHeight,
  174.             pInfo->m_rectDraw.right+ptPix_P.x, pInfo->m_rectDraw.bottom+ptPix_P.y);
  175.         m_ITGraph->SetNumProperty("PrintToDC", (int)pDC->m_hDC);
  176.         pDC->SelectClipRgn(NULL);
  177.     } else {
  178.         char tmpStr[80];
  179.         int charWidth = pDC->GetTextExtent("M", 1).cx;
  180.         int charHeight = pDC->GetTextExtent("M", 1).cy;
  181.         
  182.         CPoint pos(4 * charWidth, 2 * charHeight);
  183.         
  184.         pDC->TextOut(pos.x, pos.y, "ITGraph Property Playground");
  185.         pos.y += charHeight;
  186.         pDC->TextOut(pos.x, pos.y, "Current Graph and Associated Statistics");
  187.         pos.y += 2 * charHeight; // skip a line
  188.         
  189.         // compute bounding rectangle for the graph, 1/3 of page width, 1/5 of page height
  190.         CRect rcGraph(pos.x, pos.y, pos.x + pDC->GetDeviceCaps(HORZRES)/3, 
  191.             pos.y + pDC->GetDeviceCaps(VERTRES)/5);
  192.         // draw rectangle around graph
  193.         pDC->Rectangle(rcGraph);
  194.         
  195.         m_ITGraph->SetNumProperty("PrintToDC", 0); // select entire graph for printing
  196.         // select the target print area
  197.         m_ITGraph->SetNumProperty("PrintRectLeft", rcGraph.left);
  198.         m_ITGraph->SetNumProperty("PrintRectTop", rcGraph.top);
  199.         m_ITGraph->SetNumProperty("PrintRectWidth", rcGraph.Width());
  200.         m_ITGraph->SetNumProperty("PrintRectHeight", rcGraph.Height());
  201.         m_ITGraph->SetNumProperty("PrintToDC", (int)pDC->m_hDC); // print the graph
  202.         
  203.         pos.y += rcGraph.Height() + charHeight;
  204.         
  205.         // print the names of all nodes in the graph
  206.         int nItems = (int)m_ITGraph->GetNumProperty("ListCount");
  207.         sprintf(tmpStr, "The Graph Contains %d Nodes", nItems);
  208.         pDC->TextOut(pos.x, pos.y, tmpStr, strlen(tmpStr));
  209.         pos.y += charHeight;
  210.         for(int i = 0; i < nItems; i++) {
  211.             sprintf(tmpStr, "    Node %d: %s", i, m_ITGraph->GetStrProperty("List", i));
  212.             pDC->TextOut(pos.x, pos.y, tmpStr, strlen(tmpStr));
  213.             pos.y += charHeight;
  214.         }
  215.     }
  216. }
  217.  
  218. /////////////////////////////////////////////////////////////////////////////
  219. // CItgDemoView diagnostics
  220.  
  221. #ifdef _DEBUG
  222. void CItgDemoView::AssertValid() const
  223. {
  224.     CFormView::AssertValid();
  225. }
  226.  
  227. void CItgDemoView::Dump(CDumpContext& dc) const
  228. {
  229.     CFormView::Dump(dc);
  230. }
  231.  
  232. CItgDemoDoc* CItgDemoView::GetDocument() // non-debug version is inline
  233. {
  234.     ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CItgDemoDoc)));
  235.     return (CItgDemoDoc*)m_pDocument;
  236. }
  237. #endif //_DEBUG
  238.  
  239. /////////////////////////////////////////////////////////////////////////////
  240. // CItgDemoView message handlers
  241.  
  242. void CItgDemoView::OnSize(UINT nType, int cx, int cy)
  243. {
  244.     CFormView::OnSize(nType, cx, cy);
  245.     
  246.     if(m_ITGraph) {
  247.         CRect rcClient;
  248.         GetClientRect(&rcClient);
  249.         m_ITGraph->EnableVBXFloat();
  250.         m_ITGraph->Move(rcClient);
  251.     }
  252. }
  253.  
  254. void CItgDemoView::OnItemconnectItgraph1(UINT, int, CWnd*, LPVOID lpParams)
  255. {
  256.     short fromIx = AFX_NUM_EVENTPARAMINDEX(short, lpParams, 5);
  257.     short toIx = AFX_NUM_EVENTPARAMINDEX(short, lpParams, 3);
  258.  
  259.     m_ITGraph->SetNumProperty("ConnectTo", toIx, fromIx);
  260. }
  261.  
  262. void CItgDemoView::OnItemclickItgraph1(UINT, int, CWnd*, LPVOID lpParams)
  263. {
  264.     short ItemIx = AFX_NUM_EVENTPARAMINDEX(short, lpParams, 5);
  265.     short ItemHandle = AFX_NUM_EVENTPARAMINDEX(short, lpParams, 4);
  266.     if(ItemHandle == 0) {
  267.         m_ITGraph->SetNumProperty("SelectedIndex", ItemIx);
  268.     }
  269. }
  270.  
  271. void CItgDemoView::OnClickItgraph1(UINT, int, CWnd*, LPVOID lpParams)
  272. {  
  273.     short Button = AFX_NUM_EVENTPARAMINDEX(short, lpParams, 3);
  274.     if(Button == ITG_LeftButton)
  275.         m_ITGraph->SetNumProperty("SelectedIndex", -1);
  276. }
  277.  
  278. void CItgDemoView::OnMousedownItgraph1(UINT, int, CWnd*, LPVOID lpParams)
  279. {
  280.     short Button = AFX_NUM_EVENTPARAMINDEX(short, lpParams, 3);
  281.     if(Button == ITG_RightButton) {
  282.         CMenu popMenu;
  283.         
  284.         int isSelected = m_ITGraph->GetNumProperty("SelectedIndex") != -1;
  285.         if(isSelected)
  286.             popMenu.LoadMenu(IDR_POPUP2);
  287.         else
  288.             popMenu.LoadMenu(IDR_POPUP1);
  289.         
  290.         CMenu *pPopup = popMenu.GetSubMenu(0);
  291.         POINT pt;
  292.         ::GetCursorPos(&pt);
  293.         pPopup->TrackPopupMenu(TPM_LEFTALIGN + TPM_RIGHTBUTTON, pt.x, pt.y, GetParent());    
  294.     }
  295. }
  296.  
  297. void CItgDemoView::OnKeypressItgraph1(UINT, int, CWnd*, LPVOID lpParams)
  298. {
  299.     if(m_ITGraph->GetNumProperty("SelectedIndex") >= 0) {
  300.         short KeyCode = AFX_NUM_EVENTPARAMINDEX(short, lpParams, 0);
  301.         CString sName = m_ITGraph->GetStrProperty("List", (int)m_ITGraph->GetNumProperty("SelectedIndex"));
  302.         
  303.         if((KeyCode == '\b') && (sName.GetLength() > 0)) {
  304.             if((sName.GetLength() >= 2) && (sName.Right(2) == "\r\n"))
  305.                 sName = sName.Left(sName.GetLength()-2);
  306.             else if(sName.GetLength() >= 1)
  307.                 sName = sName.Left(sName.GetLength()-1);
  308.         } else if(KeyCode == '\r')
  309.             sName += "\r\n";
  310.         else if(KeyCode >= ' ')
  311.             sName += CString((char)KeyCode);
  312.             
  313.         m_ITGraph->SetStrProperty("List", sName, (int)m_ITGraph->GetNumProperty("SelectedIndex"));
  314.     }
  315. }
  316.  
  317. void CItgDemoView::OnSelectrectItgraph1(UINT, int, CWnd*, LPVOID lpParams)
  318. {
  319.     short L = AFX_NUM_EVENTPARAMINDEX(short, lpParams, 5);
  320.     short T = AFX_NUM_EVENTPARAMINDEX(short, lpParams, 4);
  321.     short W = AFX_NUM_EVENTPARAMINDEX(short, lpParams, 3);
  322.     short H = AFX_NUM_EVENTPARAMINDEX(short, lpParams, 2);
  323.     
  324.     m_ITGraph->SetNumProperty("SelectRectLeft", L);
  325.     m_ITGraph->SetNumProperty("SelectRectTop", T);
  326.     m_ITGraph->SetNumProperty("SelectRectWidth", W);
  327.     m_ITGraph->SetNumProperty("SelectRectHeight", H);
  328.     m_ITGraph->SetNumProperty("ZoomSelectRect", TRUE);
  329. }
  330.  
  331. void CItgDemoView::OnItemdblclickItgraph1(UINT, int, CWnd*, LPVOID lpParams)
  332. {
  333.     short Button = AFX_NUM_EVENTPARAMINDEX(short, lpParams, 3);
  334.     short ItemHandle = AFX_NUM_EVENTPARAMINDEX(short, lpParams, 4);
  335.     short ItemIx = AFX_NUM_EVENTPARAMINDEX(short, lpParams, 5);
  336.     
  337.     if((Button == ITG_LeftButton) && (ItemHandle == 0)) {
  338.         CDlgItem dlgItem(m_ITGraph, this);
  339.         dlgItem.DoModal();
  340.     }
  341. }
  342.  
  343. void CItgDemoView::OnDblclickItgraph1(UINT, int, CWnd*, LPVOID)
  344. {
  345.     m_ITGraph->SetNumProperty("DrawScale", 0);
  346. }
  347.  
  348. void CItgDemoView::OnItemmousemoveItgraph1(UINT, int, CWnd*, LPVOID)
  349. {
  350. }
  351.  
  352. void CItgDemoView::FindNode(CWnd *parWnd, CString sFindStr)
  353. {
  354.     int nItems = (int)m_ITGraph->GetNumProperty("ListCount");
  355.     int selIx = (int)m_ITGraph->GetNumProperty("SelectedIndex");
  356.  
  357.     for(int i = 1; i < nItems; i++) {
  358.         int itemIx = (selIx + i) % nItems;
  359.         CString sList = m_ITGraph->GetStrProperty("List", itemIx);
  360.         if(sList.Find(sFindStr) != -1) {
  361.             m_ITGraph->SetNumProperty("SelectRectLeft", m_ITGraph->GetNumProperty("ItemXpos", itemIx));
  362.             m_ITGraph->SetNumProperty("SelectRectTop", m_ITGraph->GetNumProperty("ItemYpos", itemIx));
  363.             m_ITGraph->SetNumProperty("SelectRectWidth", m_ITGraph->GetNumProperty("ItemWidth", itemIx));
  364.             m_ITGraph->SetNumProperty("SelectRectHeight", m_ITGraph->GetNumProperty("ItemHeight", itemIx));
  365.             m_ITGraph->SetNumProperty("ZoomSelectRect", FALSE); // scroll w/o scale change
  366.             m_ITGraph->SetNumProperty("SelectedIndex", itemIx);
  367.             return;
  368.         }
  369.     }
  370.         
  371.     parWnd->MessageBox("The string '" + sFindStr + "' was not found.");
  372. }
  373.  
  374. void CItgDemoView::RandomTree(int NodeCount)
  375. {
  376.     if(AskToSave()) {
  377.         int oldRedraw = (int)m_ITGraph->GetNumProperty("Redraw");
  378.         m_ITGraph->SetNumProperty("Redraw", FALSE);
  379.         m_ITGraph->SendMessage(VBM_METHOD, METH_CLEAR, 0L);
  380.         for(int i = 1; i <= NodeCount; i++) {
  381.             char szNodeName[16];
  382.             sprintf(szNodeName, "Node #%d", i);
  383.             m_ITGraph->AddItem(szNodeName, -1);
  384.             if(m_bRandomSizedNodes) {
  385.                 m_ITGraph->SetNumProperty("ItemWidth", rand()%200 + 25, i-1);
  386.                 m_ITGraph->SetNumProperty("ItemHeight", rand()%200 + 25, i-1);
  387.             }
  388.             if(i > 1)
  389.                 m_ITGraph->SetNumProperty("ConnectTo", i-1, rand() % (i-1));
  390.         }
  391.         m_ITGraph->SetNumProperty("Redraw", oldRedraw);
  392.     }
  393. }
  394.  
  395. void CItgDemoView::RandomDirected(int NodeCount)
  396. {
  397.     if(AskToSave()) {
  398.         int oldRedraw = (int)m_ITGraph->GetNumProperty("Redraw");
  399.         m_ITGraph->SetNumProperty("Redraw", FALSE);
  400.         m_ITGraph->SendMessage(VBM_METHOD, METH_CLEAR, 0L);
  401.         for(int i = 1; i <= NodeCount; i++) {
  402.             char szNodeName[16];
  403.             sprintf(szNodeName, "Node #%d", i);
  404.             m_ITGraph->AddItem(szNodeName, -1);
  405.             if(m_bRandomSizedNodes) {
  406.                 m_ITGraph->SetNumProperty("ItemWidth", rand()%200 + 25, i-1);
  407.                 m_ITGraph->SetNumProperty("ItemHeight", rand()%200 + 25, i-1);
  408.             }
  409.             if(i > 1)
  410.                 for(int j = rand()%3; j >= 0; j--)
  411.                     m_ITGraph->SetNumProperty("ConnectTo", i-1, rand() % (i-1));
  412.         }
  413.         m_ITGraph->SetNumProperty("Redraw", oldRedraw);
  414.     }
  415. }
  416.  
  417. int CItgDemoView::AskToSave()
  418. {
  419.     if(m_ITGraph->GetNumProperty("IsDirty")) {
  420.         CDocument *pDoc = GetDocument();
  421.         int wSave;
  422.         if(pDoc->GetPathName() == "")
  423.             wSave = MessageBox("Save changes made to the current graph?", "Save Graph?",
  424.                 MB_YESNOCANCEL | MB_ICONQUESTION);
  425.         else
  426.             wSave = MessageBox("Save changes made to '" + pDoc->GetTitle() + "'?", "Save Graph?",
  427.                 MB_YESNOCANCEL | MB_ICONQUESTION);
  428.         if(wSave == IDCANCEL)
  429.             return FALSE;
  430.         else if(wSave == IDYES) {
  431.             if(pDoc->GetPathName() != "")
  432.                 m_ITGraph->SetStrProperty("SaveAs", pDoc->GetPathName());
  433.             else {
  434.                 CFileDialog dlgSaveAs(FALSE, "itg", "*.itg", OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR | OFN_HIDEREADONLY,
  435.                     "ITGraph Files (*.itg) | *.itg | All Files (*.*) | *.* ||", this);
  436.                 if(dlgSaveAs.DoModal() == IDOK) {
  437.                     pDoc->SetPathName(dlgSaveAs.GetPathName());
  438.                     m_ITGraph->SetStrProperty("SaveAs", pDoc->GetPathName());
  439.                 } else
  440.                     return FALSE;
  441.             }
  442.         }
  443.     }
  444.     
  445.     return TRUE;
  446. }
  447. void CItgDemoView::OnLinedblclickItgraph1(UINT, int, CWnd*, LPVOID lpParams)
  448. {
  449.     short Button = AFX_NUM_EVENTPARAMINDEX(short, lpParams, 3);
  450.     short ToIx = AFX_NUM_EVENTPARAMINDEX(short, lpParams, 4);
  451.     short FromIx = AFX_NUM_EVENTPARAMINDEX(short, lpParams, 5);
  452.     
  453.     if(Button == ITG_LeftButton) {
  454.         m_ITGraph->SetNumProperty("ConnectTo", ToIx, FromIx);
  455.         CDlgLine dlgLine(m_ITGraph, GetParent());
  456.         dlgLine.DoModal();
  457.     }
  458. }
  459.